<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue组件</title>
</head>

<body>
    <div id="app">
        <my-cpn></my-cpn>
        <my-cpn></my-cpn>

        <my-cpn></my-cpn>
        <my-cpn></my-cpn>
        <!-- <local></local>报错 -->

    </div>
    <br>
    <div id="app2">
        
        <my-cpn></my-cpn>
        <localname></localname>
        <localname></localname>

        <localname></localname>


    </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

    <script>
        const tem = Vue.extend({
            template:
                '<div>我是全局组件</div>'
        });

        Vue.component('my-cpn', tem);/* 全局组件 */

        const local = Vue.extend({
            template:
                '<div>我是局部组件</div>'
        });
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue!'
            }
        })

        var app2 = new Vue({
            el: '#app2',
            data: {
                message: 'Hello Vue!'
            },
            components: {
            /* 局部 */    localname: local
            }
        })
    </script>
</body>

</html>